﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using XamlDom;
using XamlDom.Parser;
using XamlDom.Reflector;

namespace XamlDomTest
{
    [TestClass]
    public class WPFXamlLoaderFixture
    {
        [TestMethod]
        public void LoadSingleStackPanelTest()
        {
            string xamlStr = @"<Page
                                xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
                                xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
                              <StackPanel Background=""LightBlue"" Orientation=""Vertical"">
                                <TextBlock Margin=""10,10,10,10"" Text=""sunyanfei""></TextBlock>
                                <TextBlock Margin=""10,10,10,10"" Text=""sunyanfei""></TextBlock>
                              </StackPanel>
                            </Page>";

            //Register Assembly
            XamlDomInitializer.Init();

            //InitParser
            XamlParser parser = new XamlParser(xamlStr);

            //WriteToObject
            XamlToObjReader reader = new XamlToObjReader();
            WPFXamlLoader.Load(parser, reader);

            Assert.IsNotNull(reader.RootView);
        }
    }
}
